/*******************************************************************************
 *
 *      Filename: Plane.cpp
 *   Description: See Plane.h
 *        Author: [kb]ypp
 *    Created at: November 7, 2005
 * Last modified: 
 *
 ******************************************************************************/

#include "Plane.h"
#include "Vector3.h"

//! Does not perform any initialization
//!
Plane::Plane()
{}

Plane::Plane( const Plane &plane )
	: n( plane.n ), d( plane.d )
{}

Plane::Plane( const vec3 &n, float d )
	: n( n ), d( d )
{}

Plane& Plane::operator=( const Plane &plane )
{
	n = plane.n;
	d = plane.d;
	return *this;
}

//! Gives the signed distance from the plane to an arbitrary `point':
//! @f[ distance = dot( n, point ) + d  @f]
//! If distance = 0, then the `point' lies in the plane.
//! If distance > 0, then the `point' lies on the positive side of the plane
//! (on the side in with the normal vector points).
//! If distance < 0, then the `point' lies on the negative side of the plane.
//! @return @f[ distance @f]
float Plane::substitute( const vec3 &point ) const
{
	return dot( n, point ) + d;
}
